#include <bits/stdc++.h>

#include "tree.h"
using namespace std;
int dfs(TreeNode *root, int sum) {
  if (root == nullptr) {
    return 0;
  }

  int ret = 0;
  sum -= root->val;
  if (sum == 0) {
    ++ret;
  }

  ret += dfs(root->left, sum);
  ret += dfs(root->right, sum);
}

int pathSum(TreeNode *root, int targetSum) {
  if (root == nullptr) {
    return 0;
  }

  int ret = dfs(root, targetSum);
  ret += pathSum(root->left, targetSum);
  ret += pathSum(root->right, targetSum);

  return ret;
}